package com.me.dao;

import com.me.dao.db.DbSet;
import com.me.model.*;
import com.me.service.Services;

public class DbContext {
	private DbSet<User> users;
	private DbSet<Goods> goods;
	private DbSet<Type> types;
	private DbSet<Recommend> recommends;
	private DbSet<Order> orders;
	private DbSet<Orderitem> orderItems;

	public DbSet<Type> getTypes() {
		if (types == null) {
			types = new DbSet<Type>(Type.class);
		}
		Services.inject(types);
		return types;
	}

	public DbSet<User> getUsers() {
		if (users == null) {
			users = new DbSet<User>(User.class);
		}
		Services.inject(users);
		return users;
	}
	public DbSet<Goods> getGoods() {
		if (goods == null) {
			goods = new DbSet<Goods>(Goods.class);
		}
		Services.inject(goods);
		return goods;
	}

    public DbSet<Recommend> getRecommends() {
		if (recommends == null){
			recommends = new DbSet<Recommend>(Recommend.class);
		}
	    Services.inject(recommends);
        return recommends;
    }

	public DbSet<Orderitem> getOrderItems() {
		if (orderItems == null){
			orderItems = new DbSet<Orderitem>(Orderitem.class);
		}
		Services.inject(orderItems);
		return orderItems;
	}

	public DbSet<Order> getOrders() {
		if (orders == null){
			orders = new DbSet<Order>(Order.class);
		}
		Services.inject(orders);
		return orders;
	}
}
